package com.google.code.garbagecan.springdatastudy.jpa.example2.repository;

import com.google.code.garbagecan.springdatastudy.jpa.example2.domain.Customer;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
import org.springframework.data.repository.query.Param;

import java.util.List;

public interface CustomerRepository extends CrudRepository<Customer, Long> {

	Customer findByName(String name);

	List<Customer> findByLastname(String lastname);

	List<Customer> findByFirstname(String firstname);

	@Query("select c from Customer c where c.firstname = :name or c.lastname = :name")
	List<Customer> findByFirstnameOrLastname(@Param("name") String name);
}
